<?php /*
	EZ-Shop, Starter E-Commerce Platform
    Copyright (C) 2009  David Hinchliffe - FC Software Ltd

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/ ?>
<?php
	function GetChild($ParentID,$num,$selected,$obj_db)
	{
		$value = "";
		$c="&nbsp;-&nbsp";
		
		$query_RsC = "SELECT * FROM tbladscategory WHERE iParentid = ".$ParentID."  ORDER BY vName ASC";
		$RsC = $obj_db->select($query_RsC);
		$cnt = count($RsC);
		
		if($RsC)
		{
			for($i=0;$i<$cnt;$i++)
			{	
				if($selected==$RsC[$i]['iId'])
				{
				$value=$value.$c.$RsC[$i]['vName'];		
				}
				else
				{
				$value=$value.$c.$RsC[$i]['vName'];		
				}
				
				$value=$value." ".GetChild($RsC[$i]['iId'],$num+1,$selected,$obj_db);		
			 }
		 }
		return $value;
	}
	
	function Getid($ParentID,$num,$selected,$obj_db, $value)
	{
		$query_RsC = "SELECT * FROM tbladscategory WHERE iParentid = ".$ParentID."  ORDER BY vName ASC";
		$RsC = $obj_db->select($query_RsC);
		$cnt = count($RsC);
		
		if($RsC)
		{
			for($i=0;$i<$cnt;$i++)
			{	
				if($selected==$RsC[$i]['iId'])
				{
				$value=$RsC[$i]['iId'];		
				}
				else
				{
				$value=$RsC[$i]['iId'];		
				}
				
				$value=Getid($RsC[$i]['iId'],$num+1,$selected,$obj_db,$value);		
			 }
		 }
		return $value;
	}
?>